<% smtp_enabled = ForemInstance.smtp_enabled? %>

<% unless smtp_enabled %>
  <div class="crayons-card">
    <div class="crayons-card__body p-4">
      <h1 class="crayons-title">Setup SMTP to invite users</h1>
      <div class="my-4">
        SMTP settings are required so that your Forem can send emails.
        If you wish to send invites, email digests and activity notifications you will need to
        specify which email host will relay those messages for you. You can
        <a href="https://admin.forem.com/docs/advanced-customization/config/email-server-settings" target="_blank">read more about SMTP Settings in our admin guide</a>.
      </div>
      <div class="my-4">
        Please note that you will need to reload this page after configuring your SMTP Settings.
      </div>
      <div class="fw-bold">
        <%= link_to "Configure your SMTP Settings here.", admin_config_path(anchor: "smtp-section"), target: "_blank", rel: :noopener %>
      </div>
    </div>
  </div>
<% end %>

<% if smtp_enabled %>
  <h1 class="crayons-title">Invite Users</h1>
  <%= form_for(User.new, url: admin_invitations_path) do |f| %>
    <div class="crayons-field mt-6">
      <%= f.label :email, class: "crayons-field__label" %>
      <%= f.text_field :email,
                       class: "crayons-textfield",
                       placeholder: "Email of invitee",
                       required: true %>
    </div>
    <div class="crayons-field mt-6">
      <%= f.label :custom_invite_subject, "Subject (Optional)", class: "crayons-field__label" %>
      <%= f.text_field :custom_invite_subject,
                       class: "crayons-textfield",
                       placeholder: 'REPLACES "Invitation Instructions"',
                       required: true %>
    </div>
    <div class="crayons-field mt-6">
      <%= f.label :custom_invite_message, "Custom Message (Optional)", class: "crayons-field__label" %>
      <%= f.text_area :custom_invite_message,
                      class: "crayons-textfield",
                      placeholder: "REPLACES INTRO: Hello... You have been invited to join...",
                      required: true %>
    </div>
    <div class="crayons-field mt-6">
      <%= f.label :custom_invite_footnote, "Custom Footer (Optional)", class: "crayons-field__label" %>
      <%= f.text_field :custom_invite_footnote,
                       class: "crayons-textfield",
                       placeholder: "Comes right after invitation link",
                       required: true %>
    </div>
    <div class="mt-6">
      <%= f.submit "Invite User", class: "crayons-btn" %>
    </div>
  <% end %>
<% end %>
